<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
<%@ taglib uri="http://struts.apache.org/tags-nested" prefix="nested" %>

<%@ page import="lwf.factory.WordImageFactory, lwf.factory.PropertyReader, lwf.handler.entities.WordImage, net.lwf.handler.util.ImageHtml, java.util.*"%>

<%
   String backimage = request.getContextPath() + "/" + "image/math/arithmatics.jpg";
   String image = ImageHtml.getWordImage("rectangle") ;
   out.println(image);
   
      image = ImageHtml.getWordImage("rectangle", 6) ;
   out.println(image);
   
   //ImageHtml.getImageOnly("rectangle", "rectangle2");
 %>
<body>
 <form>
   <table border="0" width="75%" align="center">
      <%
          Map mapimages = PropertyReader.getInstance().getWordImages();
          Iterator iter = mapimages.entrySet().iterator();
          while(iter.hasNext()) {
             Map.Entry mapentry = (Map.Entry) iter.next();
             String imagename = (String) mapentry.getKey();
             List images = (List) mapentry.getValue();
      %>
           <tr>
              <td><%=imagename%></td>
              <td>
                  <table>
                     <tr>
		                  <%
		                      for(int i=0; i<images.size(); i++) {
		                       String imagesource = request.getContextPath() + "/" + (String) images.get(0);
		                   %>
		                   <td>
		                       <%=imagesource%>
		                   </td>
		                   <td>&nbsp;</td>
		                   <td>
		                      <img src="<%=imagesource%>" border="2">
		                   </td>
		                   <td>&nbsp;</td>
		                   <% 
		                      }
		                   %>
		             </tr>
		          </table>   
              </td>
           </tr>
      <%
          }
       %>
   </table>
   
   <table border="1" bordercolor="green">
   <%
   String imageloc = null;
        Map mapdata =   WordImageFactory.getInstance().getImageData();
		Iterator iterator = mapdata.entrySet().iterator();
		while(iterator.hasNext()) {
%>
          <tr>
<%		  
			Map.Entry mapentry = (Map.Entry) iterator.next();
			String directory = (String) mapentry.getKey();
			System.out.println("===> Directory: " + directory);
%>
             <td align="left"><font color="blue"><h2><%=directory%></h2></font></td>
             </tr>
             
             <tr>
             <td>
                <table border="0" bordercolor="blue">
<%			
			
			Map mapsub = (Map) mapentry.getValue();
			Iterator iter1 = mapsub.entrySet().iterator();
			while(iter1.hasNext()) {
%>
                   <tr>
<%			
			
			   Map.Entry mapentry1 = (Map.Entry) iter1.next();
			   String subdir = (String) mapentry1.getKey();
			   System.out.println("......... Word: " + subdir); 
%>
                      <td align="left"><h3><%=subdir%></h3></td>
                      <td>&nbsp;</td>
<%
			   
			   WordImage wi = (WordImage) mapentry1.getValue();
			   if(wi.getWordImages() == null) {
			      wi.print();
			      //String imageloc1 = request.getContextPath() + "/" + wi.getImagePath();
%>
                   <td><img src="<%=wi.getImagePath()%>"></td>
<%			      
			   }
			   else {
			      List wis = wi.getWordImages();
%>
                    <td><table border="1" bordercolor="red"><tr>
<%			      
			      
			      for(int i=0; i<wis.size(); i++) {
			         wi = (WordImage) wis.get(i);
			        //imageloc = request.getContextPath() + "/" + wi.getImagePath();
%>
                     <td><img src="<%=wi.getImagePath()%>"></td>
<%			         
			         wi.print();
			      }
%>
                    </tr></table></td>
<%			      
			   }
			   System.out.println("........................................................");
%>
                  </tr>
<%			   
			}
			System.out.println("  ");
%>
       </table></td> </tr>
<%			
			
		}   
    %>  
    </table>
 </form>
 </body>
